package com.zwps.biz.controller.http;

import com.zwps.biz.api.model.dto.region.SelectRegionDTO;
import com.zwps.biz.api.model.vo.region.RegionTreeVO;
import com.zwps.biz.api.model.vo.region.RegionVO;
import com.zwps.biz.domain.service.RegionService;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.Nullable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.List;
import java.util.Map;

/**
 * 
 * @ClassName: RegionController
 * @Description: 
 * @author lyh
 * @date 2023年8月15日 下午3:22:54
 *
 */
@Tag(name = "行政区划")
@RestController
@Validated
@RequestMapping("system/region")
public class RegionController {

    @Autowired
    private RegionService regionService;


    /**
     * 临时处理视频监控
     * @return
     */
    @GetMapping("/list")
    public List<Map<String,Object>> list() {
        return regionService.getVedioList();
    }

    /**
     * 
     * @Title: addIotProjectDevice
     * @Description:
     * @param dto void
     * @author lyh
     * @date 2023年8月15日 上午10:19:55
     */
    @Parameter(name = "regionCode", description = "行政区划编码", in = ParameterIn.PATH)
    @Operation(summary = "查询指定行政区划信息")
    @GetMapping("{regionCode}")
    public RegionVO getRegion(@Valid @NotBlank @PathVariable String regionCode) {
        return regionService.getRegion(regionCode);
    }

    @Parameter(name = "parentRegionCode", description = "上级区划编码")
    @Operation(summary = "查询行政区划权限树")
    @GetMapping("tree")
    public List<RegionTreeVO> findDeptTree(@Nullable String parentRegionCode) {
        return regionService.findTree(parentRegionCode);
    }


    @Operation(summary = "条件查询行政区划")
    @PostMapping("search")
    public List<RegionVO> searchRegion(@RequestBody SelectRegionDTO dto){
        return regionService.searchRegion(dto);
    }




}
